package com.example.demoexample.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.GridView;
import android.widget.LinearLayout;

import com.example.demoexample.R;
import com.example.demoexample.adapter.DateMonthAdapter;
import com.example.demoexample.entity.DateEntity;
import com.example.demoexample.utils.DataUtils;

import java.util.ArrayList;

public class CalenderView extends LinearLayout {

    private DateMonthAdapter adapter;
    private GridView gridView;
    private ArrayList<DateEntity> datas ;
    public CalenderView(Context context) {
        this(context,null);

    }

    public CalenderView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,-1);

    }

    public CalenderView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        LayoutInflater.from(getContext()).inflate(R.layout.view_calender,this);

        gridView = findViewById(R.id.list);
        adapter = new DateMonthAdapter(context);
        datas = new ArrayList<>();
        String date = DataUtils.getCurrDate("yyyy-MM-dd");
        adapter.setData(DataUtils.getMonth(date));
        gridView.setAdapter(adapter);
        adapter.setDateString(date);
        adapter.setSelectedPosition(DataUtils.getSelectPosition());
    }

}
